<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class adminmodel extends CI_Model {

    public function __construct() {
        parent::__construct();
    }

    public function getMenu() {
        $sql = "SELECT * FROM menu";
        $query = $this->db->query($sql);
        return $query->result();
    }
    
    public function injectMenu($name, $parent) {
        $sql = "INSERT INTO menu SET label='{$name}', parent='{$parent}'";
        $query = $this->db->query($sql);
    }
    
    public function injectPage($name, $parent) {
        $sql = "INSERT INTO pages SET name='{$name}', parent='$parent'";
        $query = $this->db->query($sql);
    }
    
    public function verifyUser($username, $password) {
        $sql = $this
                ->db
                ->where('username', $username)
                ->where('password', sha1($password))
                ->limit(1)
                ->get('users');
        if($sql->num_rows > 0) {
            return $sql->row();
        }
        else {
            echo "Could not log in";
        }
    }

}
